package cn.lg.soar.redis.serializer;


import cn.lg.soar.common.util.data.DataUtil;
import org.springframework.data.redis.serializer.RedisSerializer;
import org.springframework.data.redis.serializer.SerializationException;

/**
 * @author luguoxiang
 * 开源项目：https://gitee.com/lgx1992/lg-soar 求star！请给我star！请帮我点个star！
 */
public class IntegerRedisSerializer implements RedisSerializer<Integer> {

    @Override
    public byte[] serialize(Integer value) throws SerializationException {
        return value == null ? null : DataUtil.intToBytes(value);
    }

    @Override
    public Integer deserialize(byte[] bytes) throws SerializationException {
        return bytes == null ? null : DataUtil.byteToInt(bytes);
    }

}
